package org.nepu.scr.indexrate.converter.drillingrate.keydevice.electricsystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.electricsystem.ElectricSystem;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class ElectricSystemConverter implements AttributeConverter<ElectricSystem, String> {
    @Override
    public String convertToDatabaseColumn(ElectricSystem electricSystem) {
        return JSONUtil.toJsonStr(electricSystem);
    }

    @Override
    public ElectricSystem convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, ElectricSystem.class);
    }
}
